<!DOCTYPE html>
<html lang="zh">
<head>
  <#assign title="角色管理">
  <#include "/head.html">
</head>
  
<body>
<div class="container-fluid p-t-15">
  
  <div class="row">
    
    <div class="col-lg-12">
      <div class="card">
      
        <div class="card-toolbar clearfix">
          <form id="searchForm" class="form-inline" action="#!" method="post">
            <div class="form-group mb-2 mr-2">
              <input class="form-control" type="text" name="rolename" placeholder="角色名..">
            </div>
            <a class="btn btn-default mb-2 mr-2" type="button" onclick="refreshTable()"><i class="mdi mdi-magnify"></i> 搜索</a>
            <button class="btn btn-secondary mb-2" type="reset">重置</button>
          </form>
        </div>
      
        <div class="card-body">
        
          <div id="toolbar" class="toolbar-btn-action">
            <button id="btn_add" type="button" class="btn btn-primary m-r-5" onclick="add('新增角色')">
              <span class="mdi mdi-plus" aria-hidden="true"></span>新增
            </button>
            <button id="btn_cache" type="button" class="btn btn-default m-r-5" onclick="removeCache()">
              <span class="mdi mdi-delete" aria-hidden="true"></span>删除缓存
            </button>
          </div>
          
          <table id="bootstrap-table"></table>
          
        </div>
      </div>
    </div>
    
  </div>
  
</div>

<#include "/footer.html">

<script type="text/javascript">
var prefix = "system/role";
var listUrl = prefix + '/list';

bootstrapTable({
	url: listUrl,
    columns: [{
        field: 'id',
        title: '编号'
    }, {
        field: 'rolename',
        title: '角色名'
    }, {
        field: 'description',
        title: '具体描述'
    }, {
        field: 'operate',
        title: '操作',
        formatter: btnGroup,  // 自定义方法
        events: {
            'click .edit-btn': function (event, value, row, index) {
            	update(row.id, '编辑角色');
            },
            'click .rule-btn': function (event, value, row, index) {
            	setRules(row.id);
            },
            'click .delete-btn': function (event, value, row, index) {
            	del(row.id);
            }
        }
    }]
});

//操作按钮
function btnGroup() {
	return [
        '<a type="button" class="edit-btn btn btn-xs btn-default m-r-5" title="修改" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>',
        '<a type="button" class="rule-btn btn btn-xs btn-default m-r-5" title="设置权限" data-toggle="tooltip"><i class="mdi mdi-settings"></i></a>',
        '<a type="button" class="delete-btn btn btn-xs btn-default" title="删除" data-toggle="tooltip"><i class="mdi mdi-delete"></i></a>'
    ].join('');
}

function setRules(id) {
	layerOpen('设置权限', prefix + '/rule/' + id);
}
</script>
</body>
</html>